package com.iplant.ams.service.po.ams.fxt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.ams.fxt.AMSMeasureType;
import com.iplant.ams.service.po.ams.asset.AMSAssetStandardModel;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;

import java.io.Serializable;

/**
 * 量器具清单
 *
 * @author YouWang·Peng
 * 2023-7-24 16:29:44
 */
@DBBasePO(TableName = "ams_measuretool", CheckName = {"StandardModelID"},
        Name = false, Code = false, Active = false,
        Schemas = DBSchemas.AMS, CodeAuto = true, CodePrefix =
        "LQJ-", CodeNum = 4)
public class AMSMeasureTool extends BasePO implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField
    public int StandardModelID = 0;//资产ID
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "ams_asset_standard_model", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "StandardModelID")
    public String Name = "";

    /**
     * 标准型号编码
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "ams_asset_standard_model", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "StandardModelID")
    public String Code = "";

    @DBCondition
    @DBJoin(name = "Active", tableName = "ams_asset_standard_model", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "StandardModelID")
    public int Active = 0;

    /**
     * 规格
     */
    @DBJoin(name = "AssetModel", tableName = "ams_asset_standard_model", tableAsName = "a1",
            Schemas =
                    DBSchemas.AMS, MainTableField
            = "StandardModelID")
    public String Specifications = "";



    /**
     * 量具类型
     */
    @DBCondition
    @DBField
    public int MeasureType = 0;
    /**
     * 工装类型文本
     */
    public String MeasureTypeText = "";


    @DBCondition
    @DBJoin(name = "ClassificationID", tableName = "ams_asset_standard_model", tableAsName = "a1",
            Schemas =
                    DBSchemas.AMS, MainTableField
            = "StandardModelID")
    public int ClassificationID = 0;//资产分类ID

    @DBJoin(name = "Name", tableName = "ams_asset_classification", tableAsName = "classification1",
            Schemas =
                    DBSchemas.AMS, ConditionalJoin = "classification1.ID=a1.ClassificationID")
    public String ClassificationName = "";//资产分类名称

    @DBJoin(name = "Code", tableName = "ams_asset_classification", tableAsName = "classification1", Schemas =
            DBSchemas.AMS,
            JoinIndex = 2, ConditionalJoin
            = "classification1.ID=a1.ClassificationID")
    public String ClassificationCode = "";//资产分类编码

    @DBField
    public double MinRange = 0.0;//最小量程
    @DBField
    public double MaxRange = 0.0;//最大量程
    public String RangeText = "";//量程范围

    @DBField
    public int UnitID = 0;//单位ID
    @DBJoin(name = "Name", tableName = "mss_unit", tableAsName = "unit1", Schemas = DBSchemas.Basic,
            MainTableField = "UnitID")
    public String UnitText = "";//单位名称
    @DBJoin(name = "Code", tableName = "mss_unit", tableAsName = "unit1", Schemas = DBSchemas.Basic,
            MainTableField = "UnitID")
    public String UnitCode = "";//单位编码
    @DBField
    public double MinError = 0.0;//最小误差
    @DBField
    public double MaxError = 0.0;//最大误差

    public String ErrorText = "";//误差描述

    /**
     * 默认存放位置
     */
    @DBField
    public String Position = "";



    public AMSMeasureTool() {
        super();
    }


    public AMSMeasureTool(AMSAssetStandardModel wAMSAssetStandardModel, AMSMeasureType wAMSMeasureType){
        super();

        Name=wAMSAssetStandardModel.Name;
        Code=wAMSAssetStandardModel.Code;
        StandardModelID =wAMSAssetStandardModel.ID;
        Specifications=wAMSAssetStandardModel.AssetModel;
        Active=wAMSAssetStandardModel.Active;

        MeasureType=wAMSMeasureType.getValue();
    }

    @JsonProperty("AMSAssetInfoID")
    public int getStandardModelID() {
        return StandardModelID;
    }

    public void setStandardModelID(int standardModelID) {
        this.StandardModelID = standardModelID;
    }



    @JsonProperty("AMSAssetInfoName")
    public String getAMSAssetInfoName() {
        return Name;
    }

    public void setAMSAssetInfoName(String AMSAssetInfoName) {
        this.Name = AMSAssetInfoName;
    }

    @JsonProperty("ClassificationID")
    public int getClassificationID() {
        return ClassificationID;
    }

    public void setClassificationID(int classificationID) {
        ClassificationID = classificationID;
    }

    @JsonProperty("ClassificationName")
    public String getClassificationName() {
        return ClassificationName;
    }

    public void setClassificationName(String classificationName) {
        ClassificationName = classificationName;
    }

    @JsonProperty("ClassificationCode")
    public String getClassificationCode() {
        return ClassificationCode;
    }

    public void setClassificationCode(String classificationCode) {
        ClassificationCode = classificationCode;
    }

    @JsonProperty("MinRange")
    public double getMinRange() {
        return MinRange;
    }

    public void setMinRange(double minRange) {
        MinRange = minRange;
    }

    @JsonProperty("MaxRange")
    public double getMaxRange() {
        return MaxRange;
    }

    public void setMaxRange(double maxRange) {
        MaxRange = maxRange;
    }

    @JsonProperty("RangeText")
    public String getRangeText() {
        return String.valueOf(MinRange) + '~' + MaxRange;
    }

    public void setRangeText(String rangeText) {
        RangeText = rangeText;
    }

    @JsonProperty("UnitID")
    public int getUnitID() {
        return UnitID;
    }

    public void setUnitID(int unitID) {
        UnitID = unitID;
    }

    @JsonProperty("UnitText")
    public String getUnitText() {
        return UnitText;
    }

    public void setUnitText(String unitText) {
        UnitText = unitText;
    }

    @JsonProperty("UnitCode")
    public String getUnitCode() {
        return UnitCode;
    }

    public void setUnitCode(String unitCode) {
        UnitCode = unitCode;
    }

    @JsonProperty("MinError")
    public double getMinError() {
        return MinError;
    }

    public void setMinError(double minError) {
        MinError = minError;
    }

    @JsonProperty("MaxError")
    public double getMaxError() {
        return MaxError;
    }

    public void setMaxError(double maxError) {
        MaxError = maxError;
    }

    @JsonProperty("ErrorText")
    public String getErrorText() {
        return MinError + "~" + MaxError;
    }

    public void setErrorText(String errorText) {
        ErrorText = errorText;
    }



    @JsonProperty("Specifications")
    public String getSpecifications() {
        return Specifications;
    }

    public void setSpecifications(String specifications) {
        Specifications = specifications;
    }


    @Override
    @JsonProperty("Name")
    public String getName() {
        return Name;
    }

    @Override
    public void setName(String name) {
        Name = name;
    }
    @JsonProperty("Code")
    @Override
    public String getCode() {
        return Code;
    }

    @Override
    public void setCode(String code) {
        Code = code;
    }

    @Override
    @JsonProperty("Active")
    public int getActive() {
        return Active;
    }

    @Override
    public void setActive(int active) {
        Active = active;
    }
    @JsonProperty("Position")
    public String getPosition() {
        return Position;
    }

    public void setPosition(String position) {
        Position = position;
    }

    @JsonProperty("MeasureType")
    public int getMeasureType() {
        return MeasureType;
    }

    public void setMeasureType(int frockType) {
        MeasureType = frockType;
    }

    @JsonProperty("MeasureTypeText")
    public String getMeasureTypeText() {
        MeasureTypeText = AMSMeasureType.getEnumType(MeasureType).getLabel();
        return MeasureTypeText;
    }
}
